package com.yxr.affairs.api.tool;


import com.trello.rxlifecycle.components.support.RxAppCompatActivity;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.Api.BaseApi;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.listener.HttpOnNextListener;
import com.yxr.affairs.api.Constants;
import com.yxr.affairs.api.HttpService;
import com.yxr.affairs.api.ServerApi;
import com.yxr.affairs.utils.UserInfo;

import java.util.HashMap;

import retrofit2.Retrofit;
import rx.Observable;

public class HomeGetApi extends BaseApi {

    public HomeGetApi(HttpOnNextListener listener, RxAppCompatActivity rxAppCompatActivity) {
        super(listener,rxAppCompatActivity);
        setShowProgress(false);
        setCancel(false);
        setBaseUrl(Constants.TERRITORY);

        setCache(false);
    }

    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpService service = retrofit.create(HttpService.class);
        HashMap<String, Object> map = new HashMap<>();
        map.putAll(ServerApi.getParameter());

        map.put("banner_num", "10");
        if (UserInfo.isLogin()) {
            map.put("sessionid", UserInfo.getSessionid());
        }

        return service.getIndexData(map);
    }
}
